package cn.edu.wfit.modules.learn.service.impl.coursemangement;

import java.util.List;
import cn.edu.wfit.common.core.utils.DateUtils;
import cn.edu.wfit.modules.learn.domain.WfitStuCase;
import cn.edu.wfit.modules.learn.mapper.coursemangement.WfitStuCaseMapper;
import cn.edu.wfit.modules.learn.service.coursemangement.IWfitStuCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 学生任务记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-18
 */
@Service
public class WfitStuCaseServiceImpl implements IWfitStuCaseService
{
    @Autowired
    private WfitStuCaseMapper wfitStuCaseMapper;

    /**
     * 查询学生任务记录
     * 
     * @param id 学生任务记录主键
     * @return 学生任务记录
     */
    @Override
    public WfitStuCase selectWfitStuCaseById(Long id)
    {
        return wfitStuCaseMapper.selectWfitStuCaseById(id);
    }

    /**
     * 查询学生任务记录列表
     * 
     * @param wfitStuCase 学生任务记录
     * @return 学生任务记录
     */
    @Override
    public List<WfitStuCase> selectWfitStuCaseList(WfitStuCase wfitStuCase)
    {
        return wfitStuCaseMapper.selectWfitStuCaseList(wfitStuCase);
    }

    /**
     * 新增学生任务记录
     * 
     * @param wfitStuCase 学生任务记录
     * @return 结果
     */
    @Override
    public int insertWfitStuCase(WfitStuCase wfitStuCase)
    {
        WfitStuCase exist = new WfitStuCase();
        exist.setCaseId(wfitStuCase.getCaseId());
        exist.setStuId(wfitStuCase.getStuId());
        List<WfitStuCase> existList = wfitStuCaseMapper.selectWfitStuCaseList(exist);
        if (existList.size() > 0) {
            throw new RuntimeException("该案例已被提交，请点击修改按钮");
        }else{
            wfitStuCase.setCreateTime(DateUtils.getNowDate());
            wfitStuCase.setDelFlag("0");
            return wfitStuCaseMapper.insertWfitStuCase(wfitStuCase);
        }
    }

    /**
     * 修改学生任务记录
     * 
     * @param wfitStuCase 学生任务记录
     * @return 结果
     */
    @Override
    public int updateWfitStuCase(WfitStuCase wfitStuCase)
    {
        return wfitStuCaseMapper.updateWfitStuCase(wfitStuCase);
    }

    /**
     * 批量删除学生任务记录
     * 
     * @param ids 需要删除的学生任务记录主键
     * @return 结果
     */
    @Override
    public int deleteWfitStuCaseByIds(Long[] ids)
    {
        return wfitStuCaseMapper.deleteWfitStuCaseByIds(ids);
    }

    /**
     * 删除学生任务记录信息
     * 
     * @param id 学生任务记录主键
     * @return 结果
     */
    @Override
    public int deleteWfitStuCaseById(Long id)
    {
        return wfitStuCaseMapper.deleteWfitStuCaseById(id);
    }
}
